1 : <?php
2 : /*--------------------------------------------------------------------------+
3 : This file is part of eStudy.
4 : news/classes/class.NewsCategoryStyles.inc.php
5 : - Modulgruppe: News
6 : - Beschreibung: Klasse für die News-Kategorie eStudy-Styles.
7 : - Version: 1.1.2.4, 24/01/08
8 : - Autor(en): Corinna Kropf <corinna.kropf@mni.fh-giessen.de>
9 : +---------------------------------------------------------------------------+
10 : This program is free software; you can redistribute it and/or
11 : modify it under the terms of the GNU General Public License
12 : as published by the Free Software Foundation; either version 2
13 : of the License, or any later version.
14 : +---------------------------------------------------------------------------+
15 : This program is distributed in the hope that it will be useful,
16 : but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : GNU General Public License for more details.
19 : You should have received a copy of the GNU General Public License
20 : along with this program; if not, write to the Free Software
21 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 : +--------------------------------------------------------------------------*/
23 :
24 1 : require_once ("class.newscategory.inc.php");
25 1 : require_once ("class.style.inc.php");
26 :
27 : /**
28 : * Klasse für die News-Kategorie Styles.
29 : * @package eStudy.News
30 : * @version 1.1.2.4, 24/01/08
31 : * @author Corinna Kropf <corinna.kropf@mni.fh-giessen.de>
32 : */
33 1 : class NewsCategoryStyles extends NewsCategory
34 : {
35 : /**
36 : * Flag fuer die Anzeige der News-Eintraege
37 : * @var bool
38 : */
39 : private $dark;
40 : /**
41 : * HTML-Template
42 : * @var Template
43 : */
44 : private $newsTemplate;
45 : /**
46 : * Konstruktor
47 : */
48 : public function __construct($catID, $courses, $categorySettings = null)
49 : {
50 0 : parent::__construct($catID, $courses, $categorySettings);
51 0 : $this->newsTemplate = new Template(PATH_TO_ROOT."news/templates/newsstyle.html");
52 0 : }
53 : /**
54 : * Überschreibt die Methode der Oberklasse,
55 : * um weitere Initialisierungen vor der Ausgabe zu machen.
56 : * @see NewsCategory
57 : */
58 : public function echoNews($courseID, $usergroup = null)
59 : {
60 0 : if($courseID == 0)
61 0 : {
62 0 : $this->dark = false;
63 0 : parent::echoNews($courseID, $usergroup);
64 0 : }
65 0 : }
66 : /**
67 : * @see NewsCategory
68 : */
69 : public function isInstalled($courseID)
70 : {
71 0 : return (($courseID == 0)? true : false);
72 : }
73 : /**
74 : * @see NewsCategory
75 : */
76 : public function canSelectPeriod() {
77 0 : return false;
78 : }
79 : /**
80 : * @see NewsCategory
81 : */
82 : public function getNewsHeaderTitle($courseID = null, $type = null) {
83 0 : $newsCount = $this->news["count"];
84 0 : if ($newsCount > 1) $title = sprintf( $this->translate->_("%1\$s eStudy-Styles"), $newsCount);
85 0 : else $title = $this->translate->_("1 eStudy-Style");
86 :
87 0 : return $title;
88 : }
89 :
90 : /**
91 : * @see NewsCategory
92 : */
93 : protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = null) {
94 0 : if (isset($courseID) && isset($lastvisit))
95 0 : {
96 0 : if(!is_numeric($courseID) || !is_numeric($lastvisit)) return null;
97 :
98 0 : $this->news = array();
99 :
100 0 : $styles = Style::getStyleTemplates();
101 0 : if (!empty($styles))
102 0 : {
103 0 : $count = 0;
104 0 : foreach($styles as $style) {
105 0 : $date = explode(".", $style[3]);
106 0 : if (count($date) == 3 && mktime(23, 59, 59, intval($date[1]), intval($date[0]), intval($date[2])) >= $lastvisit) {
107 0 : $this->news["data"][] = $style;
108 0 : $count++;
109 0 : }
110 0 : }
111 0 : if ($count > 0) $this->news["count"] = $count;
112 0 : else $this->news = null;
113 0 : }
114 0 : }
115 :
116 0 : return $this->news;
117 : }
118 : /**
119 : * @see NewsCategory
120 : */
121 : protected function echoNewsEntry($entry, $courseID, $usergroup = null)
122 : {
123 0 : if(!isset($this->dark) || !isset($entry)) return;
124 :
125 0 : if ($courseID == 0)
126 0 : {
127 0 : $styleInfo1 = Data::toHTML($entry[1], false);
128 0 : $styleInfo4 = Data::toHTML($entry[4], false);
129 0 : $scriptPath = PATH_TO_ROOT."style/index.php";
130 0 : $styleInfo0 = Data::toHTML($entry[0], false);
131 0 : $cellStyle = ($this->dark ? "Dark" : "");
132 :
133 0 : $g_Styleuebernehmen = $this->translate->_("Style übernehmen");
134 :
135 0 : eval($this->newsTemplate->GetTemplate());
136 0 : $this->dark = !$this->dark;
137 0 : }
138 0 : }
139 : }
|